#pragma once
#include "basegameentity.h"
#include "statemachine.h"
#include "locations.h"
#include "entitymanager.h"
#include "level.h"

class Peon : public BaseGameEntity 
{
public:

	// Class Constructor
	Peon(int iID);

	// Class Destructor
	~Peon();

	// Virtual Initialize
	bool						Initialize();

	// Virtual Update Function
	void						Update(float fdT);

	// Draw Sprite
	void						Draw();
	
	// Add gold to bag
	void						AddGold(int iGold);

	// Returns true if bag has reached it's capacity
	bool						IsBagFull();

	// Message Handler
	bool						HandleMessage(const Telegram& message){return m_pStateMachine->HandleMessage(message);}

	// Getters
	StateMachine<Peon>*			GetFSM()const {return m_pStateMachine;}
	location_type				Location()const{return m_Location;}
	int							GetDestinationCol()const{return m_iDestinationCol;}
	int							GetDestinationRow()const{return m_iDestinationRow;}
	std::vector<AStarResult*>	GetAStar(){return m_AStarResult;}
	float						WalkingSpeed()const{return m_fWalkingSpeed;}
	double						MineStartTime()const{return m_dMineStartTime;}
	float						MiningSpeed()const {return m_fMiningSpeed;}

	// Setters
	void						SetAStar(AStarResult* pAStarResult);
	void						PopAStar(){m_AStarResult.pop_back();}
	void						SetDestination(float fPosX, float fPosY);
	void						SetBagEmpty(){m_iGoldCarried = 0;}
	void						SetMineStartTime(double dMineStartTime){m_dMineStartTime = dMineStartTime;}

	// Delta Time
	float						m_fDt;

	// Animation
	Animation					m_walkup;
	Animation					m_walkdown;
	Animation					m_walkright;
	Animation					m_walkleft;

	// Direction
	int							m_iUp;
	int							m_iDown;
	int							m_iLeft;
	int							m_iRight;

private:
	// Pointer to State Machine
	StateMachine<Peon>*			m_pStateMachine;

	// The place where the peon is situated
	location_type				m_Location;			

	// Max capacity of gold peon can carry
	int							m_iBagCapacity;	

	// Amount of gold peon is carrying
	int							m_iGoldCarried;	

	// Pointer to StarAlgorithm
	std::vector<AStarResult*>	m_AStarResult;

	// Walk Speed
	float						m_fWalkingSpeed;

	// Mining Speed
	float						m_fMiningSpeed;

	// Time When Mining Started
	double						m_dMineStartTime;

	// Destination Tiles
	int							m_iDestinationCol;
	int							m_iDestinationRow;

	
};